import React from 'react'
import { DicProTable as CustomDicProTable } from '../../customComponents'
import { createBehavior, createResource } from '@designable/core'
import { DnFC, useNodeIdProps } from '@designable/react'
import { AllSchemas } from '../../schemas'
import { AllLocales } from '../../locales'

export const DicProTable: DnFC<React.ComponentProps<any>> = (props) => {
  const nodeIdProps = useNodeIdProps()
  return (
    <div {...nodeIdProps}>
      <CustomDicProTable {...props} />
    </div>
  )
}

DicProTable.Behavior = createBehavior({
  name: 'DicProTable',
  extends: ['Field'],
  selector: (node) => node.props['x-component'] === 'DicProTable',
  designerProps: {
    propsSchema: AllSchemas.DicProTable,
  },
  designerLocales: AllLocales.DicProTable,
})

DicProTable.Resource = createResource({
  icon: 'Table',
  elements: [
    {
      componentName: 'Field',
      props: {
        type: 'void',
        'x-component': 'DicProTable',
        'x-component-props': {
          columns: {
            data: [
              {
                title: 'id',
                dataIndex: 'id',
                ellipsis: true,
                search: true,
              },
            ],
          },
          action: {
            buttons: {
              data: [
                {
                  text: '编辑',
                  type: 'primary',
                },
              ],
            },
          },
          rowKey: 'id',
        },
      },
    },
  ],
})
